import React, { useEffect, useState } from 'react';
import { getUserList } from '../../api/user';
import { Table } from 'antd';
const Index = () => {

  const [userList,setUserList] = useState()

  useEffect(()=>{
    getUserList().then(res=>{
      console.log(res.data);
      setUserList(res.data)
    })
  }, [])

  return (
    <div>
      <h3>用户列表</h3>

      <Table dataSource={userList} rowKey={'userid'} scroll={{
        y: 480
      }}>
        <Table.Column title={'序号'} render={(t,r,i)=>{
          return (<span>{i + 1}</span>)
        }}></Table.Column>
        <Table.Column title={'用户名'} dataIndex={'nickname'}></Table.Column>
        <Table.Column title={'手机号'} dataIndex={'tel'}></Table.Column>
        <Table.Column title={'用户id'} dataIndex={'userid'}></Table.Column>
      </Table>
    </div>
  );
};

export default Index;
